package com.example.myapplication;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class MyDatabaseHelper extends SQLiteOpenHelper {

    public static final String Create_Record="create table Record("
            +"id integer primary key autoincrement,"
            +"name text,"
            +"image integer,"
            +"text text,"
            +"address text)";

    public static final String Create_Collection="create table Collection("
            +"id integer primary key autoincrement,"
            +"name text)";

    public static final String Create_Plan="create table PlanList("
            +"id integer primary key autoincrement,"
            +"name text)";



    private Context mContext;

    public MyDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory,int version)
    {
        super(context,name,factory,version);
        mContext=context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(Create_Record);
        db.execSQL(Create_Collection);
        db.execSQL(Create_Plan);

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        db.execSQL("drop table if exists Record");
        db.execSQL("drop table if exists Collection");
        db.execSQL("drop table if exists PlanList");

        onCreate(db);
    }
}
